package io.renren.modules.communityService.controller;

import java.util.Arrays;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.communityService.dto.DbUserQuestionnaireDTO;
import io.renren.modules.communityService.vo.DbUserQuestionnaireVO;
import io.renren.modules.communityService.service.DbUserQuestionnaireService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 用户问卷调查
 *
 * @author chenweilong
 * @email 1433471850@qq.com
 * @date 2021-03-22 10:10:59
 */
@RestController
@RequestMapping("communityService/dbuserquestionnaire")
@Api(value = "pc用户问卷调查",tags = "pc用户问卷调查")
public class DbUserQuestionnaireController {
    @Autowired
    private DbUserQuestionnaireService dbUserQuestionnaireService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation(value = "list",notes = "list")
    public R list(DbUserQuestionnaireDTO dbUserQuestionnaire){
        PageUtils page = dbUserQuestionnaireService.queryPage(dbUserQuestionnaire);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ApiOperation(value = "info",notes = "info")
    public R info(@PathVariable("id") Integer id){
		DbUserQuestionnaireVO dbUserQuestionnaire = dbUserQuestionnaireService.getById(id);

        return R.ok().put("dbUserQuestionnaire", dbUserQuestionnaire);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation(value = "save",notes = "save")
    public R save(@RequestBody DbUserQuestionnaireDTO dbUserQuestionnaire){
		dbUserQuestionnaireService.save(dbUserQuestionnaire);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation(value = "update",notes = "update")
    public R update(@RequestBody DbUserQuestionnaireDTO dbUserQuestionnaire){
		dbUserQuestionnaireService.updateById(dbUserQuestionnaire);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ApiOperation(value = "delete",notes = "delete")
    public R delete(@RequestBody Integer[] ids){
		dbUserQuestionnaireService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
